# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgbase=python-fields
pkgname=python-fields
pkgver=5.0.0
pkgrel=16
arch=('any')
pkgdesc='A totally different take on container boilerplate'
url='https://github.com/ionelmc/python-fields'
license=('BSD')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'python-attrs')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/ionelmc/python-fields/archive/v$pkgver.tar.gz"
        python310.patch)
sha512sums=('feaba23b98271936d6dae20b1001978483c0fe89ccf217637fac536ae5814c2c02bac1c3ddc2a86dc0d2419a3b3658871018c0ea4b7905e1c2649aa905b8e5a3'
            '72876eba870204558d4f1a8216be5e2240406e669929605919b1adeb03a9cf230909d7658c26197189e61bd4005bcb00665c652bff6f14a97cdff881e6b45f80')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../python310.patch
  sed -i 's/\[pytest\]/[tool:pytest]/;s/--benchmark-disable//' setup.cfg
}

build() {
  cd "$srcdir"/python-fields-$pkgver
  python setup.py build
}

check() {
  cd "$srcdir"/python-fields-$pkgver
  # Drop performance test as it relies on characteristic
  rm tests/test_perf.py
  # Don't test the README as it imports characteristic
  python -m pytest --deselect README.rst
}

package_python-fields() {
  cd python-fields-$pkgver
  python setup.py install --root "$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
